﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RoleManage.aspx.cs" Inherits="Admin_RoleManage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>权限设置</title>
    <link href="../Styles/Default/default.css" type="text/css" rel="Stylesheet" />
    <link href="../Styles/cupertino/jquery-ui-1.9.2.custom.css" rel="stylesheet" type="text/css" />

    <script src="../Scripts/jquery-1.8.3.js" type="text/javascript"></script>

    <script src="../Scripts/jquery-ui-1.9.2.custom.js" type="text/javascript"></script>

    <script language="javascript" type="text/javascript" src="../Scripts/Common.js"></script>

    <script type="text/javascript">

        $(function () {
            $("#<%=gvRole.ClientID %> th input[type='checkbox']").click(function(){
                if($(this).attr("checked")=="checked"){
                    $(this).parent().parent().siblings().each(function(){
                       $(this).find("input[type='checkbox']").attr("checked",true); 
                    });
                }else{
                    $(this).parent().parent().siblings().each(function(){
                       $(this).find("input[type='checkbox']").attr("checked",false); 
                    });
                }
            });
            
            $("#<%=gvRole.ClientID %> a[class='Update']").click(function(event){
                $("#updateRole").dialog("open");
                event.preventDefault();
                
                $("#roleID").attr("value", $(this).parent().siblings().eq(0).find("span").html());
                $("#txtRoleName").attr("value", $(this).parent().siblings().eq(1).html());
                $("#txtRoleDesc").attr("value", $(this).parent().siblings().eq(2).html());
                
                var selectRole = $(this).parent().siblings().eq(3).find("span").html();
                
                if(selectRole == "启用"){
                    $("#selectRole")[0].selectedIndex = 0
                }else{
                    $("#selectRole")[0].selectedIndex = 1
                }
            });
            
            $("#<%=gvRole.ClientID %> a[class='Delete']").click(function(event){
                $("#delete").dialog("open");
                event.preventDefault();
                
                $("#deleteType").attr("value","role");
                $("#deleteID").attr("value",$(this).parent().siblings().eq(0).find("span").html());
            });
            
             $("#updateRole").dialog({
                bgiframe: true,
                modal: true,
                autoOpen: false,
                width: 400,
                buttons: [
			    {
			        text: "保存",
			        click: function () {
			             $(this).dialog("close");
			             
			            var txtRoleName = $("#txtRoleName").val();
			            var txtRoleDesc = $("#txtRoleDesc").val();
			            var selectRole = $("#selectRole").val();
			            var roleID = $("#roleID").val();
			            
			            $.ajax({
			                type:"POST",
			                url:encodeURI("Handler/RolerHandler.ashx?roleid="+roleID+"&rolename="+txtRoleName+"&rolerdesc="+txtRoleDesc+"&rolerenable="+selectRole+"&type=update"),
			                contentType:"application/json,charset=utf-8",
			                dataType:"JSON",
			                success:function(data){
			                    if(data != null && data == "1"){
			                        $("#<%=btnResearch.ClientID %>").click();  
			                        alert("已经更新角色信息！"); 
			                    }else{
			                        alert("修改发生错误，请联系管理员。");
			                    }
			                },
			                error:function(data){}
			            });
			        }
			    },
			    {
			        text: "取消",
			        click: function () {
			            $(this).dialog("close");
			        }
			    }
		    ]
            });
                
            $("#tabs").tabs({click:function(){
                alert();
            }});

            $("#dialog").dialog({
                bgiframe: true,
                modal: true,
                autoOpen: false,
                width: 400,
                buttons: [
				{
				    text: "保存",
				    click: function () {
				        $(this).dialog("close");
				    }
				},
				{
				    text: "取消",
				    click: function () {
				        $(this).dialog("close");
				    }
				}
			]
            });
            
            
            
            $("#delete").dialog({
                modal: true,
                autoOpen: false,
                width: 400,
                buttons: [
				{
				    text: "确认",
				    click: function () {
				        var deleteType = $("#deleteType").val();
				        var roleID = $("#deleteID").val();
				        if(deleteType != null && deleteType == "role"){
				            $.ajax({
				                type:"POST",
				                url:encodeURI("Handler/RolerHandler.ashx?roleid="+roleID+"&type=delete"),
				                contentType:"application/json,charset=utf-8",
				                dataType:"JSON",
				                success:function(data){
    				                if(data != null && data == "1"){
			                            $("#<%=btnResearch.ClientID %>").click();   
			                            alert("已经删除角色信息！");
			                        }else{
			                            alert("修改发生错误，请联系管理员。");
			                        }
				                },
				                error:function(){}    
				            });
				        }
				        
				        $(this).dialog("close");
				    }
				},
				{
				    text: "取消",
				    click: function () {
				        $(this).dialog("close");
				    }
				}
			]
            });
            $("#newItem").click(function (event) {
                $("#dialog").dialog("open");
                event.preventDefault();
            });
            $("#editItem").click(function (event) {
                $("#dialog").dialog("open");
                event.preventDefault();
            });
            $("#del").click(function (event) {
                $("#delete").dialog("open");
                event.preventDefault();
            });
        });
	</script>

    <style type="text/css">
        .style1
        {
            height: 29px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
            <tbody>
                <tr>
                    <td>
                        <div id="PageHeader_Frame1_PanelMyPrint">
                            <div style="height: 5px; font-size: 1px">
                            </div>
                            <div id="wenHou">
                                <img src="../Styles/Default/images/index1/wen.gif" width="32" height="30"><span style="color: #f5a117;
                                    font-weight: bold">&nbsp;您当前的位置：</span>办公自动化&gt;&gt;&nbsp;收费系统&gt;&gt;&nbsp;权限设置</div>
                            <div style="height: 5px; font-size: 1px">
                            </div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div id="tabs">
                            <ul>
                                <li><a href="#tabs-1">角色名称</a></li>
                                <li><a href="#tabs-2">模块名称</a></li>
                                <li><a href="#tabs-3">权限管理</a></li>
                            </ul>
                            <div id="tabs-1">
                                <table>
                                    <tr>
                                        <td>
                                            <asp:Button ID="btnRoleEnable" runat="server" Text="启 用" OnClick="btnRoleEnable_Click" />&nbsp;
                                            <asp:Button ID="btnRoleForbidden" runat="server" Text="禁 用" OnClick="btnRoleForbidden_Click" />
                                        </td>
                                    </tr>
                                </table>
                                <asp:GridView ID="gvRole" runat="server" CssClass="CSSDataGrid" BorderColor="#95BBE6"
                                    BorderWidth="1" Width="100%" AutoGenerateColumns="false">
                                    <Columns>
                                        <asp:TemplateField HeaderStyle-Width="150" ItemStyle-HorizontalAlign="Center">
                                            <HeaderTemplate>
                                                <asp:CheckBox ID="cbxSelectAll" runat="server" Text="全选" />
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <asp:CheckBox ID="cbxSelect" runat="server" />
                                                <asp:Label ID="lblRoleID" runat="server" Text='<%#Eval("roler_id") %>' Style="display: none;"></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField HeaderText="角色名称" DataField="Roler_Name" />
                                        <asp:BoundField HeaderText="角色描述" DataField="Roler_Description" />
                                        <asp:TemplateField HeaderText="是否启用？" HeaderStyle-Width="150" ItemStyle-HorizontalAlign="Center">
                                            <ItemTemplate>
                                                <asp:Label ID="lblEnable" runat="server" Text='<%#CheckRoleIsEnable(Eval("roler_isenable")) %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="操作" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="250">
                                            <ItemTemplate>
                                                <a id="lkbtnUpdate" class="Update">修改</a> <a id="lkbtnDelete" class="Delete">删除</a>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                            </div>
                            <div id="tabs-2">
                                <p>
                                    <table>
                                        <tr>
                                            <td>
                                                <input type="button" value=" 新增" id="newItem" />
                                                <input type="button" value=" 启用" />
                                                <input type="button" value=" 禁用" />
                                            </td>
                                        </tr>
                                    </table>
                                    <%--<table style="border-right-width: 0px; width: 100%; border-top-width: 0px; border-bottom-width: 0px;
                                        border-left-width: 0px" id="Table1" class="CSSDataGrid" border="0" rules="all"
                                        cellspacing="1" cellpadding="4">
                                        <tr class="HeaderStyle">
                                            <th>
                                                <input type="checkbox" id="Checkbox1" value="选择" /><label for="chk">选择</label>
                                            </th>
                                            <th>
                                                节点名称
                                            </th>
                                            <th>
                                                模块名称
                                            </th>
                                            <th>
                                                模块路径
                                            </th>
                                            <th>
                                                是否启用？
                                            </th>
                                            <th>
                                                操作
                                            </th>
                                        </tr>
                                        <tr class="ItemStyle">
                                            <td>
                                                <input type="checkbox" />
                                            </td>
                                            <td>
                                                系统维护
                                            </td>
                                            <td>
                                                参数设置
                                            </td>
                                            <td>
                                                ../main/a.aspx
                                            </td>
                                            <td>
                                                是
                                            </td>
                                            <td>
                                                <a href="#" id="editItem">修改</a>&nbsp; <a href="#" id="del">删除</a>
                                            </td>
                                        </tr>
                                        <tr class="ItemStyle">
                                            <td>
                                                <input type="checkbox" />
                                            </td>
                                            <td>
                                                系统维护
                                            </td>
                                            <td>
                                                权限管理
                                            </td>
                                            <td>
                                                ../main/a.aspx
                                            </td>
                                            <td>
                                                是
                                            </td>
                                            <td>
                                                <a href="#">修改</a>&nbsp; <a href="#">删除</a>
                                            </td>
                                        </tr>
                                        <tr class="ItemStyle">
                                            <td class="style1">
                                                <input type="checkbox" />
                                            </td>
                                            <td class="style1">
                                                收费管理
                                            </td>
                                            <td class="style1">
                                                收费模块
                                            </td>
                                            <td class="style1">
                                                ../main/a.aspx
                                            </td>
                                            <td class="style1">
                                                是
                                            </td>
                                            <td class="style1">
                                                <a href="#">修改</a>&nbsp; <a href="#">删除</a>
                                            </td>
                                        </tr>
                                        <tr class="PagerStyle" align="right">
                                            <td colspan="6">
                                                <span>&nbsp;&nbsp;共9条记录&nbsp;&nbsp;&nbsp;&nbsp;第1页/共1页&nbsp;&nbsp;&nbsp;&nbsp;</span><input
                                                    style="width: 30px" name="DataGrids:_ctl12:_ctl1"><a href="#">&nbsp;GO</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>上一页</span>&nbsp;<span>下一页</span>
                                            </td>
                                        </tr>
                                    </table>--%>
                                    <asp:GridView ID="gvModel" runat="server" CssClass="CSSDataGrid" BorderColor="#95BBE6"
                                        BorderWidth="1" Width="100%" AutoGenerateColumns="false">
                                        <Columns>
                                            <asp:TemplateField HeaderStyle-Width="150" ItemStyle-HorizontalAlign="Center">
                                                <HeaderTemplate>
                                                    <asp:CheckBox ID="cbxSelectAll" runat="server" Text="全选" />
                                                </HeaderTemplate>
                                                <ItemTemplate>
                                                    <asp:CheckBox ID="cbxSelect" runat="server" />
                                                    <asp:Label ID="lblRoleID" runat="server" Text='<%#Eval("roler_id") %>' Style="display: none;"></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            
                                            <asp:BoundField HeaderText="节点名称" DataField="Roler_Name" />
                                            <asp:BoundField HeaderText="模块名称" DataField="Roler_Description" />
                                            <asp:BoundField HeaderText="模块路径" DataField="Roler_Description" />
                                            
                                            <asp:TemplateField HeaderText="是否启用？" HeaderStyle-Width="150" ItemStyle-HorizontalAlign="Center">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblEnable" runat="server" Text='<%#CheckRoleIsEnable(Eval("roler_isenable")) %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="操作" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="250">
                                                <ItemTemplate>
                                                    <a id="lkbtnUpdate" class="Update">修改</a> <a id="lkbtnDelete" class="Delete">删除</a>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                        </Columns>
                                    </asp:GridView>
                                </p>
                            </div>
                            <div id="tabs-3">
                                <p>
                                    <p>
                                        <table>
                                            <tr>
                                                <td>
                                                    <input type="button" value=" 新增" id="Button2" />
                                                    <input type="button" value=" 启用" />
                                                    <input type="button" value=" 禁用" />
                                                </td>
                                            </tr>
                                        </table>
                                        <table style="border-right-width: 0px; width: 100%; border-top-width: 0px; border-bottom-width: 0px;
                                            border-left-width: 0px" id="Table3" class="CSSDataGrid" border="0" rules="all"
                                            cellspacing="1" cellpadding="4">
                                            <tr class="HeaderStyle">
                                                <th>
                                                    <input type="checkbox" id="Checkbox3" value="选择" /><label for="chk">选择</label>
                                                </th>
                                                <th>
                                                    权限名称
                                                </th>
                                                <th>
                                                    模块名称
                                                </th>
                                                <th>
                                                    是否启用
                                                </th>
                                                <th>
                                                    操作
                                                </th>
                                            </tr>
                                            <tr class="ItemStyle">
                                                <td>
                                                    <input type="checkbox" />
                                                </td>
                                                <td>
                                                    管理员
                                                </td>
                                                <td>
                                                    参数设置
                                                </td>
                                                <td>
                                                    是
                                                </td>
                                                <td>
                                                    <a href="#">修改</a>&nbsp; <a href="#">删除</a>
                                                </td>
                                            </tr>
                                            <tr class="ItemStyle">
                                                <td>
                                                    <input type="checkbox" />
                                                </td>
                                                <td>
                                                    管理员
                                                </td>
                                                <td>
                                                    收费
                                                </td>
                                                <td>
                                                    是
                                                </td>
                                                <td>
                                                    <a href="#">修改</a>&nbsp; <a href="#">删除</a>
                                                </td>
                                            </tr>
                                            <tr class="ItemStyle">
                                                <td>
                                                    <input type="checkbox" />
                                                </td>
                                                <td>
                                                    管理员
                                                </td>
                                                <td>
                                                    密码管理
                                                </td>
                                                <td>
                                                    是
                                                </td>
                                                <td>
                                                    <a href="#">修改</a>&nbsp; <a href="#">删除</a>
                                                </td>
                                            </tr>
                                            <tr class="ItemStyle">
                                                <td>
                                                    <input type="checkbox" />
                                                </td>
                                                <td>
                                                    管理员
                                                </td>
                                                <td>
                                                    权限设置
                                                </td>
                                                <td>
                                                    是
                                                </td>
                                                <td>
                                                    <a href="#">修改</a>&nbsp; <a href="#">删除</a>
                                                </td>
                                            </tr>
                                            <tr class="ItemStyle">
                                                <td>
                                                    <input type="checkbox" />
                                                </td>
                                                <td>
                                                    管理员
                                                </td>
                                                <td>
                                                    用户管理
                                                </td>
                                                <td>
                                                    是
                                                </td>
                                                <td>
                                                    <a href="#">修改</a>&nbsp; <a href="#">删除</a>
                                                </td>
                                            </tr>
                                            <tr class="PagerStyle" align="right">
                                                <td colspan="5">
                                                    <span>&nbsp;&nbsp;共9条记录&nbsp;&nbsp;&nbsp;&nbsp;第1页/共1页&nbsp;&nbsp;&nbsp;&nbsp;</span><input
                                                        style="width: 30px" name="DataGrids:_ctl12:_ctl1"><a href="#">&nbsp;GO</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>上一页</span>&nbsp;<span>下一页</span>
                                                </td>
                                            </tr>
                                        </table>
                                    </p>
                            </div>
                        </div>
                        <div id="dialog" title="新增" style="display: none">
                            <p>
                                <table>
                                    <tr>
                                        <td>
                                            项目名称：
                                        </td>
                                        <td>
                                            <input type="text" value="行政性收费" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            是否启用？
                                        </td>
                                        <td>
                                            <select>
                                                <option>是</option>
                                                <option>否</option>
                                            </select>
                                        </td>
                                    </tr>
                                </table>
                            </p>
                        </div>
                        <div id="delete" style="display: none">
                            <p>
                                确认删除吗？</p>
                            <input type="hidden" id="deleteType" />
                            <input type="hidden" id="deleteID" />
                        </div>
                        <div id="updateRole" title="修改" style="display: block">
                            <p>
                                <table>
                                    <tr>
                                        <td>
                                            角色名称：
                                        </td>
                                        <td>
                                            <input type="text" id="txtRoleName" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            角色描述：
                                        </td>
                                        <td>
                                            <input type="text" id="txtRoleDesc" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            是否启用？
                                        </td>
                                        <td>
                                            <select id="selectRole">
                                                <option>启用</option>
                                                <option>禁用</option>
                                            </select>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <input id="roleID" type="hidden" />
                                        </td>
                                    </tr>
                                </table>
                            </p>
                        </div>
                        <asp:Button ID="btnResearch" runat="server" OnClick="btnResearch_Click" Style="display: none;" />
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    </form>
</body>
</html>
